
/**
 * Student-Class
 * 
 * Container for the Informations of Students
 * 
 * @author Fleischhacker
 *
 */
public class Student {

	/**
	 * Unique ID for the Student
	 */
	private final int matNr;
	
	/**
	 * Name of the Student
	 */
	private String name;
	
	/**
	 * Constructor for Student
	 * @param _matNr
	 * @param _name
	 */
	Student(int _matNr, String _name){
		this.matNr = _matNr;
		this.name = _name;
	}
	
	/**
	 * Returns the unique matNr of the Student
	 * @return the matNr of the Student
	 */
	public int getMatrikelNr(){
		return this.matNr;
	}
	
	/**
	 * Returns the Name of the Student
	 * @return the Name of the Student
	 */
	public String getStudentName(){
		return this.name;
	}
	
	/**
	 * Change the Name of the Student
	 * @param _newName the (new) Student-Name
	 */
	public void setStudentName(String _newName){
		this.name = _newName;
	}

	/**
	 * Used for the Set in StudentFactory:
	 * Students are equal if their matNr matches (even if the names got different values)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		if (matNr != other.matNr)
			return false;
		return true;
	}
	
	/**
	 * hashCode-Override
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + matNr;
		return result;
	}
}
